package org.lex.splitter.util;

import java.io.PrintWriter;
import java.io.StringWriter;

public class StringUtils {
	public static final String nl = System.getProperty("line.separator", "\n");

	public static String toString(Throwable t) {
		StringWriter sw = new StringWriter();
		PrintWriter pw = new PrintWriter(sw);
		while (true) {
			t.printStackTrace(pw);
			t = t.getCause();
			if (null == t) {
				break;
			} else {
				pw.println("Caused By:");
			}
		}
		pw.flush();
		return sw.toString();
	}
}
